from django.core.management.base import BaseCommand
from faker import Faker 
from realize.models.FaStation import FaStation
from realize.models.category.FaStationCategory import FaStationCategory

import random

# mock 基站数据
class Command(BaseCommand):
    help = 'Closes the specified poll for voting'

    def add_arguments(self, parser):
        parser.add_argument('number', type=int)

    def handle(self, *args, **options):
        number = options['number']
        for i in range(number):
            station = FaStation()
            fake = Faker('zh_CN')

            latitude = random.uniform(15, 55)
            longitude = random.uniform(70, 135)
        
            station.name = fake.company()[0:-4]  
            category = random.choice(FaStationCategory.objects.all())
            station.category = category
            location = f"{latitude},{longitude}"
            station.center_location = location
            station.range = random.randint(500, 5000)

            station.save()

            self.stdout.write("ADD ----- OK")
        self.stdout.write(f"Total: {number} messages added!!!")
